feat: add picker config module with validation#32
Conversation
Add lua/uv/picker/config.lua module that handles: - Validation of picker_integration config values - Normalization with backwards compatibility (true -> "auto") - Detection of available pickers (snacks, telescope, fzf-lua) Supports values: "auto", "snacks", "telescope", "fzf-lua", false This is the first step toward implementing issue #5. https://claude.ai/code/session_01F4BSDRnA1uBGAeaCs4FmEz
Move Snacks picker logic from init.lua to lua/uv/picker/snacks.lua The module provides: - is_available(): Check if Snacks picker is available - get_commands_source(): UV commands picker source - get_venv_source(): Virtual environment picker source - setup(): Register sources with Snacks https://claude.ai/code/session_01F4BSDRnA1uBGAeaCs4FmEz
Move Telescope picker logic from init.lua to lua/uv/picker/telescope.lua The module provides: - is_available(): Check if Telescope is available - pick_uv_commands(): UV commands picker function - pick_uv_venv(): Virtual environment picker function - setup(): Create picker functions with callbacks https://claude.ai/code/session_01F4BSDRnA1uBGAeaCs4FmEz
Create lua/uv/picker/init.lua that provides: - resolve_picker(): Determine which picker to use based on config - setup(): Initialize the selected picker with callbacks - get_commands_keymap(): Get keymap command for commands picker - get_venv_keymap(): Get keymap command for venv picker Supports "auto", "snacks", "telescope", "fzf-lua", or false. https://claude.ai/code/session_01F4BSDRnA1uBGAeaCs4FmEz
Change picker_integration from boolean to support: - "auto": Try snacks first, then telescope (default) - "snacks": Explicitly use Snacks picker - "telescope": Explicitly use Telescope picker - "fzf-lua": Explicitly use fzf-lua picker - false: Disable picker integration - true: Backwards compatible, treated as "auto" https://claude.ai/code/session_01F4BSDRnA1uBGAeaCs4FmEz
Replace inline picker code with calls to the new picker module. The setup_pickers function now: - Uses uv.picker module to setup the selected picker - Exposes telescope picker functions on M for backwards compatibility This reduces init.lua by ~260 lines while maintaining functionality. https://claude.ai/code/session_01F4BSDRnA1uBGAeaCs4FmEz
Replace inline picker detection with calls to picker module. The setup_keymaps function now uses: - picker.get_commands_keymap() for command picker keymaps - picker.get_venv_keymap() for venv picker keymaps This respects the picker_integration config setting. https://claude.ai/code/session_01F4BSDRnA1uBGAeaCs4FmEz
Change condition from truthy check to explicit false check. This ensures picker setup runs for string values like "snacks". https://claude.ai/code/session_01F4BSDRnA1uBGAeaCs4FmEz
Add lua/uv/picker/fzf-lua.lua as a stub for future implementation. Currently shows a warning when selected but not implemented. Update picker factory to route fzf-lua config to the stub. https://claude.ai/code/session_01F4BSDRnA1uBGAeaCs4FmEz
Document the new picker_integration configuration: - "auto": Auto-detect picker (default) - "snacks": Use Snacks.nvim picker - "telescope": Use Telescope.nvim picker - false: Disable picker integration Also note backwards compatibility with boolean true. https://claude.ai/code/session_01F4BSDRnA1uBGAeaCs4FmEz
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f9e869d64
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| -- Expose telescope picker functions on M for backwards compatibility | ||
| local telescope_pickers = picker.get_commands_picker() | ||
| if telescope_pickers then | ||
| M.pick_uv_commands = telescope_pickers | ||
| end | ||
| local telescope_venv = picker.get_venv_picker() |
There was a problem hiding this comment.
Keep telescope functions available even when auto picks Snacks
When picker_integration is left at the default "auto" and Snacks is installed, resolve_picker selects Snacks, so picker.get_commands_picker()/get_venv_picker() return nil and M.pick_uv_commands/M.pick_uv_venv are never defined. In the previous implementation, these telescope functions were always defined when Telescope was installed, regardless of Snacks, so users with existing custom keymaps or scripts calling require('uv').pick_uv_commands() will now get a nil error whenever Snacks is present. The comment says this is for backwards compatibility, but it only works if Telescope is the resolved picker. Consider exposing these functions whenever Telescope is available, even if another picker is selected.
Useful? React with 👍 / 👎.
Add lua/uv/picker/config.lua module that handles:
Supports values: "auto", "snacks", "telescope", "fzf-lua", false
This is the first step toward implementing issue #5.
https://claude.ai/code/session_01F4BSDRnA1uBGAeaCs4FmEz